package org.ihelpuoo.orm.handler.http;

import java.lang.reflect.Field;

import javax.servlet.ServletRequest;

import org.ihelpuoo.lang.StringUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.handler.ObjectProcessor;
import org.ihelpuoo.orm.handler.ReadNormalFieldHandler;

public class HttpReadNormalFieldHandler extends ReadNormalFieldHandler
{

	public HttpReadNormalFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@Override
	protected Object evalObjectValue(ObjectRule r, Field f, Object src, String prefix)
			throws Exception
	{
		if (StringUtils.isBlank(prefix))
			return ((ServletRequest)src).getParameter(r.getAlias(f));
		return ((ServletRequest)src).getParameter(prefix + r.getAlias(f));
	}

}
